﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdFont : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdFont(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdFont_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdFont obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdFont()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdFont(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdFont cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdFont_cast(OdRxObject.getCPtr(pObj));
			OdFont result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdFont)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdFont)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdFont)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdFont_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdFont_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdFont_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdFont createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdFont_createObject();
			OdFont result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdFont)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdFont)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdFont)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public uint getFlags()
		{
			uint result = GlobalsPINVOKE.OdFont_getFlags(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public uint flags()
		{
			uint result = GlobalsPINVOKE.OdFont_flags(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setFlags(uint fontFlags)
		{
			GlobalsPINVOKE.OdFont_setFlags(this.swigCPtr, fontFlags);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void addFlag(uint fontFlags)
		{
			GlobalsPINVOKE.OdFont_addFlag(this.swigCPtr, fontFlags);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdResult initialize(OdStreamBuf pStreamBuf)
		{
			OdResult result = (OdResult)GlobalsPINVOKE.OdFont_initialize(this.swigCPtr, OdStreamBuf.getCPtr(pStreamBuf));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult drawCharacter(char character, OdGePoint2d advance, OdGiCommonDraw pWd, OdTextProperties textProperties)
		{
			OdResult result = (OdResult)GlobalsPINVOKE.OdFont_drawCharacter__SWIG_0(this.swigCPtr, character, OdGePoint2d.getCPtr(advance), OdGiCommonDraw.getCPtr(pWd), OdTextProperties.getCPtr(textProperties));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult drawCharacter(char character, OdGePoint2d advance, OdGiConveyorGeometry pGeometry, OdTextProperties textProperties)
		{
			OdResult result = (OdResult)GlobalsPINVOKE.OdFont_drawCharacter__SWIG_1(this.swigCPtr, character, OdGePoint2d.getCPtr(advance), pGeometry.GetCPtr(), OdTextProperties.getCPtr(textProperties));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual double getAbove()
		{
			double result = GlobalsPINVOKE.OdFont_getAbove(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual double getBelow()
		{
			double result = GlobalsPINVOKE.OdFont_getBelow(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual uint getAvailableChars(OdCharArray characters)
		{
			uint result = GlobalsPINVOKE.OdFont_getAvailableChars(this.swigCPtr, OdCharArray.getCPtr(characters));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool hasCharacter(char character)
		{
			bool result = GlobalsPINVOKE.OdFont_hasCharacter(this.swigCPtr, character);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual double getHeight()
		{
			double result = GlobalsPINVOKE.OdFont_getHeight(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual double getInternalLeading()
		{
			double result = GlobalsPINVOKE.OdFont_getInternalLeading(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public double fontAbove()
		{
			double result = GlobalsPINVOKE.OdFont_fontAbove(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual double getUnderlinePos(double textSize)
		{
			double result = GlobalsPINVOKE.OdFont_getUnderlinePos(this.swigCPtr, textSize);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual double getOverlinePos(double textSize)
		{
			double result = GlobalsPINVOKE.OdFont_getOverlinePos(this.swigCPtr, textSize);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool isShxFont()
		{
			bool result = GlobalsPINVOKE.OdFont_isShxFont(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual double getAverageWidth()
		{
			double result = GlobalsPINVOKE.OdFont_getAverageWidth(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void getScore(ushort character, OdGePoint2d advance, OdGePoint3d pointsOver, OdGePoint3d pointsUnder, OdTextProperties textFlags)
		{
			GlobalsPINVOKE.OdFont_getScore(this.swigCPtr, character, OdGePoint2d.getCPtr(advance), OdGePoint3d.getCPtr(pointsOver), OdGePoint3d.getCPtr(pointsUnder), OdTextProperties.getCPtr(textFlags));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual uint getFontData(uint dwTable, uint dwOffset, IntPtr pBuffer, uint cbData)
		{
			uint result = GlobalsPINVOKE.OdFont_getFontData(this.swigCPtr, dwTable, dwOffset, pBuffer, cbData);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool supportsVerticalMode()
		{
			bool result = GlobalsPINVOKE.OdFont_supportsVerticalMode(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual string getFileName()
		{
			string result = GlobalsPINVOKE.OdFont_getFileName(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void getDescriptor(OdTtfDescriptor descr)
		{
			GlobalsPINVOKE.OdFont_getDescriptor(this.swigCPtr, OdTtfDescriptor.getCPtr(descr));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual int getLogFont(IntPtr lpLogFont)
		{
			int result = GlobalsPINVOKE.OdFont_getLogFont(this.swigCPtr, lpLogFont);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public const int kBigFont10 = 1;

		public const int kUniFont10 = 2;

		public const int kFont10 = 4;

		public const int kFont11 = 8;

		public const int kFont10A = 16;

		public const int kTrueType = 32;

		public const int kFontGdt = 64;

		public const int kFontSimplex6 = 128;

		public const int kShapes11 = 256;

		public const int kFontRsc = 512;

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
